<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //求最大值
        // 1.定义数组
        let arr = [2, 6, 1, 77, 55.25, 7]
        // 2.接收每次比较后最大值,先取出第一个值
        let num = arr[0]
        for (let i = 0; i < arr.length; i++) {
            //以打擂台形式比较
            if (arr[i] < arr[i + 1]) {
                num = arr[i + 1]
            }
        } console.log(num)
    </script>
</body>

</html>